package designpatterns.prototype.demo02;

import java.util.Date;

/**
 * @author 真香
 * @create 2021-05-30 16:21
 *  原型模式
 */


// 无良UP主，搬运视频
public class Video implements Cloneable {

    public Video(String name, Date create) {
        this.name = name;
        this.create = create;
    }

    // 视频名称
    private String name;
    // 发布日期
    private Date create;


    @Override
    protected Object clone() throws CloneNotSupportedException {
        Object obj = super.clone();

        // 实现深克隆

        Video v =(Video) obj;
        // 将对象的属性也克隆
        v.create =(Date) this.create.clone();
        return obj;

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreate() {
        return create;
    }

    public void setCreate(Date create) {
        this.create = create;
    }

    @Override
    public String toString() {
        return "Video{" +
                "name='" + name + '\'' +
                ", create=" + create +
                '}';
    }
}
